#include <windows.h>
#include <iostream>

int main(int argc, char* argv[]) {
    
    char* dll = (argc > 1) ? argv[1] : "D3D12Core.dll";

    const int length = 512;
#ifdef _UNICODE
    wchar_t dest[length];
    MultiByteToWideChar(CP_ACP, 0, dll, -1, dest, length);
#else
    char* dest = dll;
#endif
    
    // Load the DLL
    HMODULE hModule = LoadLibrary(dest);
    if (hModule == NULL) {
        std::cerr << "Failed to load module: " << dest << std::endl;
        return 1;
    }

    // Get the address of the exported UINT variable
    UINT* pValue = (UINT*)GetProcAddress(hModule, "D3D12SDKVersion");
    if (pValue == NULL) {
        std::cerr << "Failed to get address of exported variable: D3D12SDKVersion" << std::endl;
        FreeLibrary(hModule);
        return 1;
    }

    // Print the value
    std::cout << "D3D12SDKVersion Value: " << *pValue << std::endl;

    // Get the address of the exported UINT variable
    char** pStr = (char**)GetProcAddress(hModule, "D3D12SDKPath");
    if (pStr == NULL) {
        std::cerr << "Failed to get address of exported variable: D3D12SDKPath" << std::endl;
        FreeLibrary(hModule);
        return 1;
    }

    // Print the value
    std::cout << "D3D12SDKPath Value: " << *pStr << std::endl;

    // Clean up
    FreeLibrary(hModule);
    return 0;
}
